﻿/* **********************************************************************************
 *
 * Copyright (c) WickedFlame Projects. All rights reserved.
 *
 * This source code is subject to terms and conditions of the Microsoft Reciprocal License
 * for WickedFlame. A copy of the license can be found in the License.html file
 * at the root of this distribution. 
 * By using this source code in any fashion, you are agreeing to be bound by
 * the terms of the Microsoft Reciprocal License for WickedFlame.
 *
 * You must not remove this notice, or any other, from this software.
 *
 * **********************************************************************************/
using System;
using System.Windows.Forms;
using System.ComponentModel;

namespace Gencode.Controls.NavigationPane
{
	public class NavigationPaneItem
	{
        public NavigationPaneItem()
        {
            this.DisplayControl = new Control();

            this.toolStripButton = new ToolStripButton();
            toolStrip = new ToolStrip();

            this.toolStrip.SuspendLayout();
            this.toolStrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
            this.toolStrip.Items.Add(this.toolStripButton);
            this.toolStrip.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.VerticalStackWithOverflow;
            this.toolStrip.Location = new System.Drawing.Point(0, 0);
            //this.toolStrip.Name = "toolStrip2";
            this.toolStrip.Size = new System.Drawing.Size(177, 55/*25*/);
            //this.toolStrip.TabIndex = 1;
            //this.toolStrip.Text = "toolStrip2";

            //this.toolStripButton1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton1.Image")));
            this.toolStripButton.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.toolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripButton.Size = new System.Drawing.Size(175, 50/*20*/);
            this.toolStripButton.Text = "button";
            this.toolStripButton.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.toolStripButton.TextImageRelation = System.Windows.Forms.TextImageRelation.Overlay;
            //this.toolStripButton.Click += new System.EventHandler(this.toolStripButton1_Click);

            this.toolStrip.ResumeLayout(false);
            this.toolStrip.PerformLayout();
        }

		public NavigationPaneItem(Control display, string text)
		{
			this.DisplayControl = display;
            this.toolStripButton = new ToolStripButton();
			this.toolStrip = new ToolStrip();

			this.toolStrip.SuspendLayout();
			this.toolStrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
			this.toolStrip.Items.Add(this.toolStripButton);
			this.toolStrip.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.VerticalStackWithOverflow;
			this.toolStrip.Location = new System.Drawing.Point(0, 0);
            //this.toolStrip.Name = "toolStrip2";
			this.toolStrip.Size = new System.Drawing.Size(177, 55/*25*/);
            //this.toolStrip.TabIndex = 1;
            //this.toolStrip.Text = "toolStrip2";

			//this.toolStripButton1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton1.Image")));
			this.toolStripButton.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.toolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta;
			this.toolStripButton.Size = new System.Drawing.Size(175, 50/*20*/);
			this.toolStripButton.Text = text;
			this.toolStripButton.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			this.toolStripButton.TextImageRelation = System.Windows.Forms.TextImageRelation.Overlay;
            this.toolStripButton.Click += new System.EventHandler(this.toolStripButton_Click);

			this.toolStrip.ResumeLayout(false);
			this.toolStrip.PerformLayout();
		}

		public Control DisplayControl
		{
			get;
			set;
		}

		ToolStrip toolStrip;
		public ToolStrip Button
		{
			get
			{
				return toolStrip;
			}
			set
			{
				toolStrip = value;
			}
		}

		ToolStripButton toolStripButton;

		public System.Drawing.Image Image
		{
			set
			{
				toolStripButton.Image = value;
			}
		}

		public int Width
		{
			set
			{
				toolStripButton.Width = value;
				DisplayControl.Width = value;
			}
		}

        // The text to display inside the control.
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
		public string Text
		{
			set
			{
				toolStripButton.Text = value;
			}
		}


        private void toolStripButton_Click(object sender, EventArgs e)
        {
            if (PaneClick != null)
                PaneClick(sender, new NavigationButtonClickEventArgs(DisplayControl));
        }

        public event NavigationButtonClickEventHandler PaneClick;
	}

    public delegate void NavigationButtonClickEventHandler(object sender, NavigationButtonClickEventArgs e);

    public class NavigationButtonClickEventArgs : EventArgs
    {
        private Control nextControl;

        public NavigationButtonClickEventArgs(Control nextControl)
            : base()
        {
            this.nextControl = nextControl;
        }

        public Control NextControl
        {
            get
            {
                return (nextControl);
            }
        }
    }
}
